import random
import sys

def autogen(n,m, out):
	sep = 1024 / m
	offset = 20
	f = open(out, 'w')
	#writting vertices and generating edges with random weight
	w = []
	for i in range(n):
		for j in range(m):
			to_write = str(i*m+j)+','+str(sep*j+offset+random.randint(-10,10))+','+str(sep*i+offset+random.randint(-10,10))+',\n'
			f.write(to_write)
			
			edge = str(i*m+j)+','+str((i*m+j)+1)+','+str(random.randint(1,99))+',\n' #right
			if j < m-1:
				w.append(edge)
			edge = str(i*m+j)+','+str((i*m+j)+m)+','+str(random.randint(1,99))+',\n' #down
			if i < n-1:	
				w.append(edge)
	#writting edges
	f.write('edges:\n')
	for i in w:
		f.write(i)
	f.close()

if __name__ == "__main__":
	autogen(int(sys.argv[1]),int(sys.argv[2]),sys.argv[3])
